package com.cxx.controller;

import com.cxx.log.Log;
import com.cxx.pojo.Result;
import com.cxx.service.MessageService;
import com.cxx.utils.JwtUtils;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/person-web/api/*")
@RestController
public class MessageController {
    @Autowired
    private JwtUtils jwtUtils;
    @Autowired
    private MessageService messageService;
    @GetMapping("/GetPersonalMessage")
    @Log
    public Result getPersonalMessage(String token){
        Claims claims=jwtUtils.parseJwt(token);
        String account= (String) claims.get("name");
        return Result.sucess(messageService.getPersonalMessage(account));
    }
}
